﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using Nova_DAL;

public partial class Search_TrayMaterial : System.Web.UI.Page
{
    string strSQL = "";
    DbHelper access = new DbHelper();
    DbCommand cmd = null;
    decimal SumCost = 0;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    }
    protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
    {
        BindGrid();
    }
    protected void ibtnReSet_Click(object sender, ImageClickEventArgs e)
    {
        txtMat_Code.Text = "";
        txtMat_Name.Text = "";
        //txtS01.Text = "";
    }

    private void BindGrid()
    {
        string WCode = Request.Cookies["WType"].Value;
        strSQL = @"select TTM.Pos_ID,TTM.TRAY_ID,TBM.MAT_CODE,TBM.MAT_NAME,TBM.S01,TTM.CDT from dbo.tbTrayMaterial  as TTM
                    left join dbo.TBase_Material as TBM on TTM.MAT_CODE=TBM.MAT_CODE WHERE 1=1 and (WID='" + WCode + "' or 'FSSC'='" + WCode + "')";

        if (!string.IsNullOrEmpty(txtMat_Code.Text))
        {
            strSQL += " and TTM.MAT_CODE='" + txtMat_Code.Text.Trim() + "'";
        }

        strSQL += " order by TTM.CDT DESC";
        cmd = access.GetSqlStringCommond(strSQL);
        gv.DataSource = access.ExecuteDataSet(cmd);
        gv.DataBind();
    }
}
